/*
* ECARX Technology Limited is the owner of the copyright and the trade secret of this software.
* Without permission, no one has the right to obtain, disclose or use this software in any way.
*/

package ecarx.xsf.notificationcenter.wrapper;

import android.os.RemoteException;

import ecarx.xsf.notificationcenter.interfaces.OnSceneCardListener;
import ecarx.xsf.notificationcenter.scenecard.ISceneCardInfo;
import ecarx.xsf.notificationcenter.scenecard.ISceneCardInfoV2;
import ecarx.xsf.notificationcenter.scenecard.ISceneCardListenerV2;

/**
 * FileName: SceneCardListener.java <br>
 * Description : 智能卡片回调接口封装 <br>
 * Create Time: 2021/8/19 17:30 <br>
 * Update Time: 2021/8/19 17:30 <br>
 *
 * @since 1.0.0
 */
public class SceneCardListenerWrapper extends ISceneCardListenerV2.Stub {

    private final OnSceneCardListener listener;
    public SceneCardListenerWrapper(OnSceneCardListener listener){
        this.listener = listener;
    }

    @Override
    public void onSceneCardPosted(ISceneCardInfoV2 cardInfo) throws RemoteException {
        if(listener != null) {
            ISceneCardInfo info = new ISceneCardInfo(cardInfo.getId(),cardInfo.getPkgname(),cardInfo.isBeep(),cardInfo.isTts(),
                    cardInfo.isSeeSay(), cardInfo.getTitle(),cardInfo.getSubtitle(),cardInfo.getBackground(),
                    cardInfo.getDetailImg(),cardInfo.getTag(),cardInfo.getWhen(),cardInfo.getActions(),
                    cardInfo.getSeeSayActions(),cardInfo.getSmartCardActions());
            listener.onSceneCardPosted(info);
        }
    }

    @Override
    public void onSceneCardRemoved(ISceneCardInfoV2 cardInfo) throws RemoteException {
        if (listener != null) {
            ISceneCardInfo info = new ISceneCardInfo(cardInfo.getId(),cardInfo.getPkgname(),cardInfo.isBeep(),cardInfo.isTts(),
                    cardInfo.isSeeSay(), cardInfo.getTitle(),cardInfo.getSubtitle(),cardInfo.getBackground(),
                    cardInfo.getDetailImg(),cardInfo.getTag(),cardInfo.getWhen(),cardInfo.getActions(),
                    cardInfo.getSeeSayActions(),cardInfo.getSmartCardActions());
            listener.onSceneCardRemoved(info);
        }
    }

    @Override
    public void onQuickCardPosted(ISceneCardInfoV2 cardInfo) throws RemoteException {
        if (listener != null) {
            ISceneCardInfo info = new ISceneCardInfo(cardInfo.getId(),cardInfo.getPkgname(),cardInfo.isBeep(),cardInfo.isTts(),
                    cardInfo.isSeeSay(), cardInfo.getTitle(),cardInfo.getSubtitle(),cardInfo.getBackground(),
                    cardInfo.getDetailImg(),cardInfo.getTag(),cardInfo.getWhen(),cardInfo.getActions(),
                    cardInfo.getSeeSayActions(),cardInfo.getSmartCardActions());
            listener.onQuickCardPosted(info);
        }
    }

    @Override
    public boolean onSceneInfoInShowing() throws RemoteException {
        if (listener != null) {
            return listener.onSceneInfoInShowing();
        }
        return false;
    }
}
